package cn.tedu.hospital.admin.server.statistics.controller;

import cn.tedu.hospital.admin.server.common.pojo.vo.PageData;
import cn.tedu.hospital.admin.server.common.web.JsonResult;
import cn.tedu.hospital.admin.server.statistics.pojo.param.BadUseRatioParam;
import cn.tedu.hospital.admin.server.statistics.pojo.vo.PatientStatisticsVO;
import cn.tedu.hospital.admin.server.statistics.pojo.vo.PayDetailStatisticsVO;
import cn.tedu.hospital.admin.server.statistics.service.IPayDetailService;
import cn.tedu.hospital.admin.server.statistics.service.IStatisticsService;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * 处理统计分析相关请求的控制器类
 *
 * @author java@tedu.cn
 * @version 1.0
 */
@Slf4j
@RestController
@RequestMapping("/statist")
@Api(tags = "1.1. 统计分析模块")
public class StatisticsController {

    @Autowired
    private IStatisticsService statisticsService;

    @Autowired
    private IPayDetailService payDetailService;

    @PostMapping("/beds")
    @ApiOperation("病床利用率查询")
    @ApiOperationSupport(order = 400)
    public JsonResult list(Integer pageNum, String division, String doctorName){
        log.debug("开始处理【查询病人信息】的请求，页码：{}, 参数, 科别:{}, 医师:{}", pageNum, division, doctorName);
        PageData<PatientStatisticsVO> pageData = statisticsService.listByParam(pageNum, division, doctorName);
        return JsonResult.ok(pageData);
    }

    @GetMapping("/pays")
    @ApiOperation("收费明细查询")
    @ApiOperationSupport(order = 410)
    public JsonResult listInPay(Integer pageNum){
        log.debug("开始处理【查询病人收费明细列表】的请求, 页码：{}", pageNum);
        PageData<PayDetailStatisticsVO> pageData = payDetailService.listInPay(pageNum);
        return JsonResult.ok(pageData);
    }

    @PostMapping("/pays/name")
    @ApiOperation("根据姓名收费明细查询")
    @ApiOperationSupport(order = 405)
    public JsonResult listInPay(String name){
        log.debug("开始处理【查询病人收费明细列表】的请求, 病人姓名：{}", name);
        PayDetailStatisticsVO payDetailStatisticsVO = payDetailService.PayByName(name);
        return JsonResult.ok(payDetailStatisticsVO);
    }

}
